<template>
  <div class="login">
    <div style="width: 100%; margin-bottom: 15px;">
      <img class="banner" width="100%"  src="@/assets/images/banner.png" />
    </div>
    <div>
      <div class="test-list" >
        <div v-for="item in formList" class="list-row">
          <div class="left">
            <div class="title">
              {{item.fromname}}
            </div>
            <!--<div class="cell">
              <span class="label">开始时间</span>
              <span class="time">{{item.startDate}}</span>
            </div>
            <div class="cell">
              <span class="label">结束时间</span>
              <span class="time">{{item.endDate}}</span>
            </div>
            -->
          </div>
          <div class="right">
            <button 
              class="submit-btn" 
              v-if="item.isInput == '启用'"
              @click="handleGo(item)"
            >进入</button>
            <!-- <button 
              class="submit-btn" 
              v-if="item.isInput != '启用'"
              @clil="handleGo(item)"
            >进入</button> -->
            <button class="submit-btn disabled-btn" disabled v-else >未开始</button>
          </div>
        </div>
      </div>
    </div>
    <!-- <table>
      <tr v-for="item in formList">
        <td @click="handleGo(item)">{{ item.fromname }}</td>
      </tr>
    </table> -->
  </div>
</template>


<script>


import { getFromInfo,getFromInfoList } from '@/api/index.js'
export default {
  name: "selectprj",
  data() {
    return {
      imageSrc: require('../assets/images/banner.png'),
      formList:[]
    };
  },

  created() {
     
    this.queryFormList();
    

  },
  methods: {
    queryFormList () {
     
      if(localStorage.getItem("openId")==null)
      {
        this.$router.push({ path: "/"});
        return;
      }
      let that = this;
      getFromInfoList().then(res=>{
        if(res.code==0)
        {
          that.formList = res.data;
        }
      });
    },
    handleGo(item) {
      let that = this;
      //获取项目信息和当前用户是否有登记的记录
      localStorage.setItem("projectId",item.fromid);
      let param = {'fromId':item.fromid,'openId':localStorage.getItem("openId")};
      getFromInfo(param).then(res=>{

        if(res.code==0)
        {


          localStorage.setItem("formInfo",JSON.stringify(res.data));

          if(res.data.dataId!=null)
          {

            that.$router.push({ path: "/viewfrom?tablefid="+res.data.dataId});
          }
          else{
            if(res.data.isWhite=='是')
            {
              that.$router.push({ path: "/checkidn"});
            }else
            {
               that.$router.push({ path: "/viewfrom"}); 
            }
          }
        }
        else
        {
            that.$message.error('系统开小差了，请重试')
            localStorage.setItem("projectId",'');
            localStorage.setItem("formInfo",'');

        }
      });
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.login {
  // display: flex;
  // justify-content: center;
  // align-items: center;
  height: 100%;
  /*background-image: url("../assets/image/login-background.jpg");*/
  background-size: cover;
  background: #f7f7f7;
  
}
.submit-btn{
  border: 1px solid #f07d17;
    background: #fff;
    border-radius: 20px;
    padding: 2px 15px;
    font-size: 14px;
    color: #f07d17;
}
.submit-btn:focus{
  background: #f07d17;
  border: 1px solid #ffffff;
  border-radius: 20px;
  color: #fff;
}
.disabled-btn{
  background: #e5e5e5;
  border: 1px solid #e5e5e5;
  color: #444;
}
.list-row{
  display: flex;
  justify-content: space-between;
  padding: 10px 15px;
  background: #fff;
  margin: 10px;
  box-shadow: 0 2px 14px 0 #ececec;
  border-radius: 6px;
  .title{
    font-size: 16px;
    font-weight: 600;
    color: #333;
    text-align: left;
    margin: 0;
    margin-bottom: 10px;
  }
}
.test-list{
  color: #666;
  .label{
    color: #666;
    font-size: 12px;
  }
}

</style>
